<!-- 指派项目经理 -->
<template>
  <a-card :bordered="false" class="card-area">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <!-- 搜索区域 -->
      <a-form style="margin-left: 15%; margin-top: 20px">
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="项目经理">
          <a-select
            v-if="model.roleName != '租户'"
            :placeholder="roleName"
            :dropdownMatchSelectWidth="false"
            style="width: 250px"
            @change="handleSelectChange"
          >
            <a-select-option v-for="(item, index) in arrList" :key="index" :value="item.id">
              {{ item.username }}
            </a-select-option>
          </a-select>
          <a-col v-if="model.roleName == '租户'"><a-row>租户</a-row></a-col>
        </a-form-item>
        <a-form-item label="登录名称" :labelCol="labelCol" :wrapperCol="wrapperCol" >
          <a-input v-model="dlmc" disabled style="width: 250px" />
        </a-form-item>
        <a-form-item label="用户姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-model="yongh" disabled style="width: 250px" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="职位">
          <a-input v-model="zhiw" disabled style="width: 250px" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="电话号码">
          <a-input v-model="dianh" disabled style="width: 250px" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="电子邮箱">
          <a-input v-model="youx" disabled style="width: 250px" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="描述">
          <a-input v-model="miaos" disabled style="width: 250px" />
        </a-form-item>
      </a-form>
    </div>
    <div style="text-align: center">
      <a-button @click="onCommit" type="primary">提交</a-button>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
  </a-card>
</template>
<script>
import Vue from 'vue'
import { findupdatePojectUser, updatePojectUser,designatePerson } from '@/api/api'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'
export default {
  name: 'projectManagerList',
  mixins: [JeecgListMixin],
  components: {},
  props: ["designate"],
  data() {
    return {
      roleName:'',
      data_d:'',
      arrList: [],
      dlmc: '',
      yongh: '',
      zhiw: '',
      dianh: '',
      youx: '',
      miaos: '',
      userId: '',
      model: {
        username: '',
        roleName: '',
      },
      // dataSource1: '',
      // 查询条件
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      url: {
        list: '/user/list',
      },
    }
  },
  created() {
    this.a()
    this.manageList()
    //  console.log(this.$route.query.id, 8989)
    // console.log(this.userId, 8888)
  },
  computed: {},
  methods: {
    // 列表数据
    a(){
      console.log(this.designate,'指定')
      this.data_d = this.designate.designate
      this.dlmc = this.data_d.loginName
      this.yongh = this.data_d.username
      this.zhiw = this.data_d.position
      this.dianh= this.data_d.phonenum
      this.youx = this.data_d.email
      this.miaos = this.data_d.description
      this.userId=this.data_d.id
      this.roleName = this.data_d.userName
    },
    manageList() {
      updatePojectUser({
        currentPage: 1,
        pageSize: 100,
        order: 1,
        column: 1,
      }).then((res) => {
        if (res.code === 200) {
          console.log(res)
          this.arrList = (res.data.rows||[]).filter((item) => item.roleName === '项目经理')
          // console.log(this.arrLis, 'arrList')
        }
      })
    },
    // 下拉加载 请求数据
    handleSelectChange(record) {
      this.dlmc = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].loginName
        : ''
      this.yongh = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].username
        : ''
      this.zhiw = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].position
        : ''
      this.dianh = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].phonenum
        : ''
      this.youx = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].email
        : ''
      this.miaos = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].description
        : ''
      this.userId = this.arrList.filter((item) => item.id == record)[0]
        ? this.arrList.filter((item) => item.id == record)[0].id
        : ''
    },

    onCommit() {
      findupdatePojectUser({
        engineeringId: this.id,
        projectUser: this.userId,
      }).then((res) => {
        if (res.code === 0) {
          this.$message.success('提交成功')
        } else {
          this.$message.warning(res.message)
        }
      })
    },
  },
}
</script>

<style scoped>
@import '~@assets/less/common.less';
</style>
